﻿using AuthCenter.API.Application.Command.Account;
using AuthCenter.Domain.Account;
using AuthCenter.ErrorCode;
using AuthCenter.Intertructrue.Interface;
using MediatR;

namespace AuthCenter.API.Application.Handler.Account
{
    public class GetXianHandler : IRequestHandler<GetXianCommand, APIResult<List<XianModel>>>
    {
        private readonly IBaseRepository<XianModel> xianRepo;

        public GetXianHandler(IBaseRepository<XianModel> xianRepo)
        {
            this.xianRepo = xianRepo;
        }
        public Task<APIResult<List<XianModel>>> Handle(GetXianCommand request, CancellationToken cancellationToken)
        {
            APIResult<List<XianModel>> result = new APIResult<List<XianModel>>();
            var res = xianRepo.GetAll().Where(x => x.IsDel == false&&x.CityId==request.CityId).ToList();
            result.Message = "显示成功";
            result.Code = APIEnum.Ok;
            result.Data = res;
            return Task.FromResult(result);
        }
    }
}
